package com.fxd.model.common;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author xudongfu
 * @date 2025/06/14
 */
@Data
@Accessors(chain = true)
public class R {

    private Integer code;

    private String msg;

    private Object data;

    public static R ok() {
        return new R()
                .setCode(200)
                .setMsg("成功");
    }

    public static R ok(String msg, Object data) {
        return new R()
                .setCode(200)
                .setMsg(msg)
                .setData(data);
    }

    public static R error() {
        return new R()
                .setCode(500)
                .setMsg("失败");
    }

    public static R error(Integer code, String msg) {
        return new R()
                .setCode(code)
                .setMsg(msg);
    }
}
